package com.hly.versioncontroladmin.controller;

import com.hly.versioncontroladmin.domain.Bo.VcDownloadLogBo;
import com.hly.versioncontroladmin.domain.VcDownloadLog;
import com.hly.versioncontroladmin.result.PageQuery;
import com.hly.versioncontroladmin.result.Result;
import com.hly.versioncontroladmin.service.VcDownloadLogService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@RestController
@RequestMapping("/api/downloadLog")
@RequiredArgsConstructor
public class VcDownloadLogController {

    private final VcDownloadLogService downloadLogService;

    @GetMapping("/{id}")
    public Result getById(@PathVariable("id") String id){
        return Result.ok(downloadLogService.getById(id));
    }

    @GetMapping("/list")
    public Result list(PageQuery<VcDownloadLog> pageQuery, VcDownloadLogBo bo){
        return Result.ok(downloadLogService.listQuery(pageQuery, bo));
    }

    @PostMapping("/saveOrUpdate")
    public Result saveOrUpdate(@RequestBody VcDownloadLog downloadLog){
        return Result.ok(downloadLogService.saveOrUpdate(downloadLog));
    }

    @PostMapping("/del/{ids}")
    public Result del(@PathVariable("ids") String ids){
        return Result.ok(downloadLogService.removeBatchByIds(Arrays.asList(ids.split(","))));
    }
}
